import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import ElementUI from 'element-ui'; //element
import 'element-ui/lib/theme-chalk/index.css';
import axios from 'axios'
import VueAxios from 'vue-axios' 
import jsCookie from 'js-cookie'
Vue.prototype.$cookie = jsCookie;
Vue.prototype.$axios=axios
// Vue.use(VueAxios,axios)
Vue.use(ElementUI);
Vue.config.productionTip = false
// axios.defaults.baseURL = "http://192.168.1.84:8081/";
// element消息提示
import {Message} from "element-ui";
let messageInstance = null;
const overrideMessage = (options) => {
  if(messageInstance) {
    messageInstance.close();
  }
  messageInstance = Message(options);
};
["error","success","info","warning"].forEach(type => {
  overrideMessage[type] = options => {
    if (typeof options === "string") {
      options = {
        message: options
      };
    }
    options.type = type;
    return overrideMessage(options);
  };
});
/***重写message**/
Vue.use(ElementUI, {
  size: "small",
  zIndex: 3000
});
Vue.prototype.$message = overrideMessage;
//全局守卫鉴权进入
router.beforeEach((to, from, next) => {
  if (to.path == '/Login'||jsCookie.get('Token')) {
    next();
  } else {
      next({ path: '/Login' });//返回登录授权，并且记录需要返回的路由
  }
});
new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
